import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login/Login')
  },
  {
    path: '/layout',
    redirect: 'layout/home',
    component: () => import('@/views/layout/Layout'),
    children: [
      {
        path: '/layout/home',
        name: 'Home',
        component: () => import('@/views/home/Home'),
        meta: {
          keepAlive: true
        }
      },
      {
        path: '/layout/qa',
        name: 'Qa',
        component: () => import('@/views/qa/Qa')
      },
      {
        path: '/layout/video',
        name: 'Video',
        component: () => import('@/views/qa/Qa')
      },
      {
        path: '/layout/profile',
        name: 'Profile',
        component: () => import('@/views/profile/Profile')
      }
    ]
  },
  {
    path: '/search',
    component: () => import('@/views/search/Search')
  },
  {
    path: '/essay/:essayId',
    name: 'Essay',
    component: () => import('@/views/essay/Essay'),
    props: true
  },
  {
    path: '/editdata',
    name: 'Editdata',
    component: () => import('@/views/editdata/Editdata')
  }
]

const router = new VueRouter({
  routes
})

export default router
